****Prepping Data Set for Replication file/Cutting down Huge data set for upload
use "C:/Users/ptucker/Dropbox/Campaign Effects/Replication/replication_data_Tucker_Smith_POBE.dta"
**Table 1
***House 14
*Initial Democrat
tab NOV142PARTY_hou if DEM14_HOU==1
*Initial Republican
tab NOV142PARTY_hou if REP14_HOU==1
*Initial Undecided
tab NOV142PARTY_hou if OTHER14_HOU==1


***Senate 14
*Initial Democrat
tab NOV142PARTY_sen if DEM14_SEN==1
*Initial Republican
tab NOV142PARTY_sen if REP14_SEN==1
*Initial Undecided
tab NOV142PARTY_sen if OTHER14_SEN==1


***House 16
*Initial Democrat
tab NOV162PARTY_hou if DEM16_HOU==1
*Initial Republican
tab NOV162PARTY_hou if REP16_HOU==1
*Initial Undecided
tab NOV162PARTY_hou if OTHER16_HOU==1


***Senate 16
*Initial Democrat
tab NOV162PARTY_sen if (DEM16_SEN==1 & STATE!="CA")
*Initial Republican
tab NOV162PARTY_sen if (REP16_SEN==1 & STATE!="CA")
*Initial Undecided
tab NOV162PARTY_sen if (OTHER16_SEN==1 & STATE!="CA")

***President 16
*Initial Democrat
tab NOV162PARTY_pres if (CLINTON_MAY==1 )
*Initial Republican
tab NOV162PARTY_pres if (TRUMP_MAY==1)
*Initial Undecided
tab NOV162PARTY_pres if (OTHER_MAY==1 )

gen SOPH01=(SOPHISTICATION+4.750437)/(2.572318+4.750437)
gen SOPHSQ=SOPH01-SOPH01^2


gen SOPH01_REPSEN16PRIM=SOPH01*REP16_SEN
gen SOPH01_OTHERSEN16PRIM=SOPH01*OTHER16_SEN
gen SOPH01_REPHOU16PRIM=SOPH01*REP16_HOU
gen SOPH01_OTHER16PRIM=SOPH01*OTHER16_HOU
gen SOPH01_TRUMPMAY=SOPH01*TRUMP_MAY
gen SOPH01_OTHERMAY=SOPH01*OTHER_MAY
gen SOPH01_REPSEN14PRIM=SOPH01*REP14_SEN
gen SOPH01_OTHERSEN14PRIM=SOPH01*OTHER14_SEN
gen SOPH01_REPHOU14PRIM=SOPH01*REP14_HOU
gen SOPH01_OTHERHOU14PRIM=SOPH01*OTHER14_HOU


gen SOPHSQ_REPSEN16PRIM=SOPHSQ*REP16_SEN
gen SOPHSQ_OTHERSEN16PRIM=SOPHSQ*OTHER16_SEN
gen SOPHSQ_REPHOU16PRIM=SOPHSQ*REP16_HOU
gen SOPHSQ_OTHER16PRIM=SOPHSQ*OTHER16_HOU
gen SOPHSQ_TRUMPMAY=SOPHSQ*TRUMP_MAY
gen SOPHSQ_OTHERMAY=SOPHSQ*OTHER_MAY
gen SOPHSQ_REPSEN14PRIM=SOPHSQ*REP14_SEN
gen SOPHSQ_OTHERSEN14PRIM=SOPHSQ*OTHER14_SEN
gen SOPHSQ_REPHOU14PRIM=SOPHSQ*REP14_HOU
gen SOPHSQ_OTHERHOU14PRIM=SOPHSQ*OTHER14_HOU


***Table 2 Columns 1-3
**House 14
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHSQ SOPHSQ_REPHOU14PRIM SOPHSQ_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 [pw=weights_hou14]     

matrix V = e(V)

**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHSQ
lincom abchou14100


****Initial REP HOU
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM
lincom SOPHSQ + SOPHSQ_REPHOU14PRIM
lincom abchou14100+abchou14_REP14100


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM
lincom SOPHSQ + SOPHSQ_OTHERHOU14PRIM
lincom abchou14100+abchou14_OTHER14100


margins, at(OBAMA_APPR_S36==(-2(1)2) REP14_HOU==0 OTHER14_HOU==0 REP_REPHOU14PRIM==0 REP_OTHERHOU14PRIM==0 DEM_REPHOU14PRIM==0 DEM_OTHERHOU14PRIM==0 abchou14_REP14100==0 abchou14_OTHER14100==0 OBAMA_REPHOU14PRIM==0 OBAMA_OTHERHOU14PRIM==0 SOPHSQ_REPHOU14PRIM==0 SOPHSQ_OTHERHOU14PRIM==0)

**Table 2 Columns 4-6
****Senate 14
logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM SOPHSQ SOPHSQ_REPSEN14PRIM SOPHSQ_OTHERSEN14PRIM abcsen14100 abcsen14_REP14100 abcsen14_OTHER14100 [pw=weights_sen14]
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHSQ
lincom abcsen14100


****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM
lincom SOPHSQ + SOPHSQ_REPSEN14PRIM
lincom abcsen14100+abcsen14_REP14100


***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
lincom SOPHSQ + SOPHSQ_OTHERSEN14PRIM
lincom abcsen14100+abcsen14_OTHER14100

****Table 3 Columns 7-9
****President

logit NOV162PARTY_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY SOPHSQ SOPHSQ_TRUMPMAY SOPHSQ_OTHERMAY OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY abcpres100 absolute_closeness_pres_REP16100 abcp_OTHER16100 [pw=weights_pres16]
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom abcpres100

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom SOPHSQ + SOPHSQ_TRUMPMAY
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom abcpres100 + absolute_closeness_pres_REP16100

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom SOPHSQ + SOPHSQ_OTHERMAY
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom abcpres100 + abcp_OTHER16100

***Table 3 Columns 4-6
***Senate model
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  SOPHSQ SOPHSQ_REPSEN16PRIM SOPHSQ_OTHERSEN16PRIM REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16 [pw=weights_sen16]  if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom SOPHSQ + SOPHSQ_REPSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16

***Initial Other
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom SOPHSQ + SOPHSQ_OTHERSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16

***House 16
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM  SOPHSQ SOPHSQ_REPHOU16PRIM SOPHSQ_OTHER16PRIM REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM absolute_closeness_hou absolute_closeness_hou_REP16 absolute_closeness_hou_OTHER16 [pw=weights_hou16]
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_hou

***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom SOPHSQ + SOPHSQ_REPHOU16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_REP16

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom SOPHSQ + SOPHSQ_OTHER16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_OTHER16


****Predicted Values for Figure 1

***Panel 1
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHSQ SOPHSQ_REPHOU14PRIM SOPHSQ_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 if (OTHER14_HOU==0 & REP14_HOU==0) [pw=weights_hou14]
margins, at(OBAMA_APPR_S36==(-2(1)2) )

***Panel 2
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHSQ SOPHSQ_REPHOU14PRIM SOPHSQ_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 if REP14_HOU==1 [pw=weights_hou14]
margins, at(OBAMA_APPR_S36==(-2(1)2) )

***Panel 3
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHSQ SOPHSQ_REPHOU14PRIM SOPHSQ_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 if OTHER14_HOU==1 [pw=weights_hou14]
margins, at(OBAMA_APPR_S36==(-2(1)2) )

foreach x of varlist ISSUESA1S55- ISSUESA6S55 ISSUESA9S55 ISSUESA10S55 ISSUESC1S55- ISSUESC6S55 ISSUESC9S55 ISSUESC10S55 ISSUESA1S60-ISSUESA6S60 ISSUESA9S60 ISSUESA10S60 ISSUESC1S60-ISSUESC6S60 ISSUESC9S60 ISSUESC10S60{
recode `x' -1=. 1=1 2=-1 3=0
}

foreach x of varlist ISSUESA7S55 ISSUESA8S55 ISSUESC7S55 ISSUESC8S55 ISSUESA7S60 ISSUESA8S60 ISSUESC7S60 ISSUESC8S60{
recode `x' -1=. 1=-1 2=1 3=0
}

gen id_pres16_dem_prim=ISSUESA1S55+ISSUESA2S55+ISSUESA3S55+ISSUESA4S55+ISSUESA5S55+ISSUESA6S55+ISSUESA7S55+ISSUESA8S55+ISSUESA9S55+ISSUESA10S55
gen id_pres16_rep_prim=ISSUESC1S55 +ISSUESC2S55 +ISSUESC3S55+ ISSUESC4S55+ ISSUESC5S55 +ISSUESC6S55 +ISSUESC7S55+ ISSUESC8S55 +ISSUESC9S55+ ISSUESC10S55
gen id_pres16_dem_nov=ISSUESA1S60+ ISSUESA2S60+ ISSUESA3S60 +ISSUESA4S60+ ISSUESA5S60+ ISSUESA6S60+ ISSUESA7S60 +ISSUESA8S60+ ISSUESA9S60 +ISSUESA10S60
gen id_pres16_rep_nov=ISSUESC1S60+ ISSUESC2S60 +ISSUESC3S60 +ISSUESC4S60+ ISSUESC5S60+ ISSUESC6S60 +ISSUESC7S60+ ISSUESC8S60 +ISSUESC9S60+ ISSUESC10S60

gen id_pres16_dem_diff=id_pres16_dem_nov-id_pres16_dem_prim
gen id_pres16_rep_diff=id_pres16_rep_nov-id_pres16_rep_prim
gen abdiff_pres16_prim=abs(id_pres16_dem_prim-id_pres16_rep_prim)
gen abdiff_pres16_nov=abs(id_pres16_dem_nov-id_pres16_rep_nov)
gen abdiff_pres16_camp=abs(abdiff_pres16_prim-abdiff_pres16_nov)



***Changing ideology

****REMEMBER: GfK screwed up JUNE HOUSE EVALS SO WE ARE MISSING A LOT OF REPUBLICANS!!!
gen id_hou16_dem_prim=PRIM_HOU_TAX_DEM+PRIM_HOU_COMCORE_DEM+PRIM_HOU_IMMIG_DEM+PRIM_HOU_GUN_DEM+PRIM_HOU_GAYM_DEM+PRIM_HOU_ABORT_DEM+PRIM_HOU_PIPELINE_DEM+PRIM_HOU_OBAMACARE_DEM+PRIM_HOU_GREENHOUSE_DEM+PRIM_HOU_ISIS_DEM 
gen id_hou16_rep_prim=PRIM_HOU_TAX_REP+PRIM_HOU_COMCORE_REP+PRIM_HOU_IMMIG_REP+PRIM_HOU_GUN_REP+PRIM_HOU_GAYM_REP+PRIM_HOU_ABORT_REP+PRIM_HOU_PIPELINE_REP+PRIM_HOU_OBAMACARE_REP+PRIM_HOU_GREENHOUSE_REP+PRIM_HOU_ISIS_REP
gen id_sen16_dem_prim=PRIM_SEN_TAX_DEM+PRIM_SEN_COMCORE_DEM+PRIM_SEN_IMMIG_DEM+PRIM_SEN_GUN_DEM+PRIM_SEN_GAYM_DEM+PRIM_SEN_ABORT_DEM+PRIM_SEN_PIPELINE_DEM+PRIM_SEN_OBAMACARE_DEM+PRIM_SEN_GREENHOUSE_DEM+PRIM_SEN_ISIS_DEM 
gen id_sen16_rep_prim=PRIM_SEN_TAX_REP+PRIM_SEN_COMCORE_REP+PRIM_SEN_IMMIG_REP+PRIM_SEN_GUN_REP+PRIM_SEN_GAYM_REP+PRIM_SEN_ABORT_REP+PRIM_SEN_PIPELINE_REP+PRIM_SEN_OBAMACARE_REP+PRIM_SEN_GREENHOUSE_REP+PRIM_SEN_ISIS_REP

gen id_hou16_dem_nov=NOV_HOU_TAX_DEM+NOV_HOU_COMCORE_DEM+NOV_HOU_IMMIG_DEM+NOV_HOU_GUN_DEM+NOV_HOU_GAYM_DEM+NOV_HOU_ABORT_DEM+NOV_HOU_PIPELINE_DEM+NOV_HOU_OBAMACARE_DEM+NOV_HOU_GREENHOUSE_DEM+NOV_HOU_ISIS_DEM 
gen id_hou16_rep_nov=NOV_HOU_TAX_REP+NOV_HOU_COMCORE_REP+NOV_HOU_IMMIG_REP+NOV_HOU_GUN_REP+NOV_HOU_GAYM_REP+NOV_HOU_ABORT_REP+NOV_HOU_PIPELINE_REP+NOV_HOU_OBAMACARE_REP+NOV_HOU_GREENHOUSE_REP+NOV_HOU_ISIS_REP
gen id_sen16_dem_nov=NOV_SEN_TAX_DEM+NOV_SEN_COMCORE_DEM+NOV_SEN_IMMIG_DEM+NOV_SEN_GUN_DEM+NOV_SEN_GAYM_DEM+NOV_SEN_ABORT_DEM+NOV_SEN_PIPELINE_DEM+NOV_SEN_OBAMACARE_DEM+NOV_SEN_GREENHOUSE_DEM+NOV_SEN_ISIS_DEM 
gen id_sen16_rep_nov=NOV_SEN_TAX_REP+NOV_SEN_COMCORE_REP+NOV_SEN_IMMIG_REP+NOV_SEN_GUN_REP+NOV_SEN_GAYM_REP+NOV_SEN_ABORT_REP+NOV_SEN_PIPELINE_REP+NOV_SEN_OBAMACARE_REP+NOV_SEN_GREENHOUSE_REP+NOV_SEN_ISIS_REP

gen id_hou16_dem_diff=id_hou16_dem_nov-id_hou16_dem_prim
gen id_hou16_rep_diff=id_hou16_rep_nov-id_hou16_rep_prim
gen id_sen16_dem_diff=id_sen16_dem_nov-id_sen16_dem_prim
gen id_sen16_rep_diff=id_sen16_rep_nov-id_sen16_rep_prim

gen abdiff_hou16_prim=abs(id_hou16_dem_prim-id_hou16_rep_prim)
gen abdiff_sen16_prim=abs(id_sen16_dem_prim-id_sen16_rep_prim)
gen abdiff_hou16_nov=abs(id_hou16_dem_nov-id_hou16_rep_nov)
gen abdiff_sen16_nov=abs(id_sen16_dem_nov-id_sen16_rep_nov)

gen abdiff_hou16_camp=abs(abdiff_hou16_prim-abdiff_hou16_nov)
gen abdiff_sen16_camp=abs(abdiff_sen16_prim-abdiff_sen16_nov)

***Change in DKs
*****Not sure as medium value
foreach x of varlist PRIM_HOU_TAX_DEM PRIM_HOU_COMCORE_DEM PRIM_HOU_IMMIG_DEM PRIM_HOU_GUN_DEM PRIM_HOU_GAYM_DEM PRIM_HOU_ABORT_DEM PRIM_HOU_PIPELINE_DEM PRIM_HOU_OBAMACARE_DEM PRIM_HOU_GREENHOUSE_DEM PRIM_HOU_ISIS_DEM PRIM_HOU_TAX_REP PRIM_HOU_COMCORE_REP PRIM_HOU_IMMIG_REP PRIM_HOU_GUN_REP PRIM_HOU_GAYM_REP PRIM_HOU_ABORT_REP PRIM_HOU_PIPELINE_REP PRIM_HOU_OBAMACARE_REP PRIM_HOU_GREENHOUSE_REP PRIM_HOU_ISIS_REP PRIM_SEN_TAX_DEM PRIM_SEN_COMCORE_DEM PRIM_SEN_IMMIG_DEM PRIM_SEN_GUN_DEM PRIM_SEN_GAYM_DEM PRIM_SEN_ABORT_DEM PRIM_SEN_PIPELINE_DEM PRIM_SEN_OBAMACARE_DEM PRIM_SEN_GREENHOUSE_DEM PRIM_SEN_ISIS_DEM PRIM_SEN_TAX_REP PRIM_SEN_COMCORE_REP PRIM_SEN_IMMIG_REP PRIM_SEN_GUN_REP PRIM_SEN_GAYM_REP PRIM_SEN_ABORT_REP PRIM_SEN_PIPELINE_REP PRIM_SEN_OBAMACARE_REP PRIM_SEN_GREENHOUSE_REP PRIM_SEN_ISIS_REP NOV_HOU_TAX_DEM NOV_HOU_COMCORE_DEM NOV_HOU_IMMIG_DEM NOV_HOU_GUN_DEM NOV_HOU_GAYM_DEM NOV_HOU_ABORT_DEM NOV_HOU_PIPELINE_DEM NOV_HOU_OBAMACARE_DEM NOV_HOU_GREENHOUSE_DEM NOV_HOU_ISIS_DEM NOV_HOU_TAX_REP NOV_HOU_COMCORE_REP NOV_HOU_IMMIG_REP NOV_HOU_GUN_REP NOV_HOU_GAYM_REP NOV_HOU_ABORT_REP NOV_HOU_PIPELINE_REP NOV_HOU_OBAMACARE_REP NOV_HOU_GREENHOUSE_REP NOV_HOU_ISIS_REP NOV_SEN_TAX_DEM NOV_SEN_COMCORE_DEM NOV_SEN_IMMIG_DEM NOV_SEN_GUN_DEM NOV_SEN_GAYM_DEM NOV_SEN_ABORT_DEM NOV_SEN_PIPELINE_DEM NOV_SEN_OBAMACARE_DEM NOV_SEN_GREENHOUSE_DEM NOV_SEN_ISIS_DEM NOV_SEN_TAX_REP NOV_SEN_COMCORE_REP NOV_SEN_IMMIG_REP NOV_SEN_GUN_REP NOV_SEN_GAYM_REP NOV_SEN_ABORT_REP NOV_SEN_PIPELINE_REP NOV_SEN_OBAMACARE_REP NOV_SEN_GREENHOUSE_REP NOV_SEN_ISIS_REP{
recode  `x' -1=0 1=0 0=1
}

foreach x of varlist ISSUESA1S55- ISSUESC10S55 ISSUESA1S60- ISSUESC10S60{
recode  `x' -1=0 1=0 0=1
}

gen dks_hou16_dem_prim=PRIM_HOU_TAX_DEM+PRIM_HOU_COMCORE_DEM+PRIM_HOU_IMMIG_DEM+PRIM_HOU_GUN_DEM+PRIM_HOU_GAYM_DEM+PRIM_HOU_ABORT_DEM+PRIM_HOU_PIPELINE_DEM+PRIM_HOU_OBAMACARE_DEM+PRIM_HOU_GREENHOUSE_DEM+PRIM_HOU_ISIS_DEM 
gen dks_hou16_rep_prim=PRIM_HOU_TAX_REP+PRIM_HOU_COMCORE_REP+PRIM_HOU_IMMIG_REP+PRIM_HOU_GUN_REP+PRIM_HOU_GAYM_REP+PRIM_HOU_ABORT_REP+PRIM_HOU_PIPELINE_REP+PRIM_HOU_OBAMACARE_REP+PRIM_HOU_GREENHOUSE_REP+PRIM_HOU_ISIS_REP
gen dks_sen16_dem_prim=PRIM_SEN_TAX_DEM+PRIM_SEN_COMCORE_DEM+PRIM_SEN_IMMIG_DEM+PRIM_SEN_GUN_DEM+PRIM_SEN_GAYM_DEM+PRIM_SEN_ABORT_DEM+PRIM_SEN_PIPELINE_DEM+PRIM_SEN_OBAMACARE_DEM+PRIM_SEN_GREENHOUSE_DEM+PRIM_SEN_ISIS_DEM 
gen dks_sen16_rep_prim=PRIM_SEN_TAX_REP+PRIM_SEN_COMCORE_REP+PRIM_SEN_IMMIG_REP+PRIM_SEN_GUN_REP+PRIM_SEN_GAYM_REP+PRIM_SEN_ABORT_REP+PRIM_SEN_PIPELINE_REP+PRIM_SEN_OBAMACARE_REP+PRIM_SEN_GREENHOUSE_REP+PRIM_SEN_ISIS_REP
gen dks_pres16_dem_prim=ISSUESA1S55+ISSUESA2S55+ISSUESA3S55+ISSUESA4S55+ISSUESA5S55+ISSUESA6S55+ISSUESA7S55+ISSUESA8S55+ISSUESA9S55+ISSUESA10S55
gen dks_pres16_rep_prim=ISSUESC1S55 +ISSUESC2S55 +ISSUESC3S55+ ISSUESC4S55+ ISSUESC5S55 +ISSUESC6S55 +ISSUESC7S55+ ISSUESC8S55 +ISSUESC9S55+ ISSUESC10S55

gen dks_hou16_dem_nov=NOV_HOU_TAX_DEM+NOV_HOU_COMCORE_DEM+NOV_HOU_IMMIG_DEM+NOV_HOU_GUN_DEM+NOV_HOU_GAYM_DEM+NOV_HOU_ABORT_DEM+NOV_HOU_PIPELINE_DEM+NOV_HOU_OBAMACARE_DEM+NOV_HOU_GREENHOUSE_DEM+NOV_HOU_ISIS_DEM 
gen dks_hou16_rep_nov=NOV_HOU_TAX_REP+NOV_HOU_COMCORE_REP+NOV_HOU_IMMIG_REP+NOV_HOU_GUN_REP+NOV_HOU_GAYM_REP+NOV_HOU_ABORT_REP+NOV_HOU_PIPELINE_REP+NOV_HOU_OBAMACARE_REP+NOV_HOU_GREENHOUSE_REP+NOV_HOU_ISIS_REP
gen dks_sen16_dem_nov=NOV_SEN_TAX_DEM+NOV_SEN_COMCORE_DEM+NOV_SEN_IMMIG_DEM+NOV_SEN_GUN_DEM+NOV_SEN_GAYM_DEM+NOV_SEN_ABORT_DEM+NOV_SEN_PIPELINE_DEM+NOV_SEN_OBAMACARE_DEM+NOV_SEN_GREENHOUSE_DEM+NOV_SEN_ISIS_DEM 
gen dks_sen16_rep_nov=NOV_SEN_TAX_REP+NOV_SEN_COMCORE_REP+NOV_SEN_IMMIG_REP+NOV_SEN_GUN_REP+NOV_SEN_GAYM_REP+NOV_SEN_ABORT_REP+NOV_SEN_PIPELINE_REP+NOV_SEN_OBAMACARE_REP+NOV_SEN_GREENHOUSE_REP+NOV_SEN_ISIS_REP
gen dks_pres16_dem_nov=ISSUESA1S60+ ISSUESA2S60+ ISSUESA3S60 +ISSUESA4S60+ ISSUESA5S60+ ISSUESA6S60+ ISSUESA7S60 +ISSUESA8S60+ ISSUESA9S60 +ISSUESA10S60
gen dks_pres16_rep_nov=ISSUESC1S60+ ISSUESC2S60 +ISSUESC3S60 +ISSUESC4S60+ ISSUESC5S60+ ISSUESC6S60 +ISSUESC7S60+ ISSUESC8S60 +ISSUESC9S60+ ISSUESC10S60



gen dkdiff_hou16_dem=dks_hou16_dem_nov-dks_hou16_dem_prim
gen dkdiff_hou16_rep=dks_hou16_rep_nov-dks_hou16_rep_prim 
gen dkdiff_sen16_dem=dks_sen16_dem_nov-dks_sen16_dem_prim
gen dkdiff_sen16_rep=dks_sen16_rep_nov-dks_sen16_rep_prim
gen dkdiff_pres16_rep=dks_pres16_rep_nov-dks_pres16_rep_prim
gen dkdiff_pres16_dem=dks_pres16_dem_nov-dks_pres16_dem_prim

gen race_sumdk_hou16_prim=dks_hou16_dem_prim+dks_hou16_rep_prim
gen race_sumdk_hou16_nov=dks_hou16_dem_nov+dks_hou16_rep_nov
gen race_sumdk_sen16_nov=dks_hou16_dem_nov+dks_hou16_rep_nov
gen race_sumdk_sen16_prim=dks_sen16_dem_prim+dks_sen16_rep_prim
gen race_sumdk_pres16_prim=dks_pres16_dem_prim+dks_pres16_rep_prim
gen race_sumdk_pres16_nov=dks_pres16_dem_nov+dks_pres16_rep_nov

gen race_dkdiff_hou16=race_sumdk_hou16_nov-race_sumdk_hou16_prim
gen race_dkdiff_sen16=race_sumdk_sen16_nov-race_sumdk_sen16_prim
gen race_dkdiff_pres16=race_sumdk_pres16_nov-race_sumdk_pres16_prim

reg race_dkdiff_hou16 SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN absolute_closeness_hou [pw=weights_hou16] 
reg race_dkdiff_sen16 SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN absolute_closeness_sen [pw=weights_sen16] 
reg race_dkdiff_pres16 SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN abcpres100 [pw=weights_pres16] 

reg dkdiff_hou16_dem SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN absolute_closeness_hou [pw=weights_hou16] 
reg dkdiff_hou16_rep SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN absolute_closeness_hou [pw=weights_hou16] 

reg dkdiff_sen16_dem SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN absolute_closeness_sen [pw=weights_sen16] 
reg dkdiff_sen16_rep SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN absolute_closeness_sen [pw=weights_sen16] 

reg dkdiff_pres16_dem SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN abcpres100 [pw=weights_pres16] 
reg dkdiff_pres16_rep SOPHISTICATION OBAMA_APPR_S60 i.REP_MAXN i.DEM_MAXN abcpres100 [pw=weights_pres16] 


gen dk_demadvant_gain_pres=(dks_pres16_rep_nov-dks_pres16_dem_nov)-(dks_pres16_rep_prim-dks_pres16_dem_prim)
gen dk_demadvant_gain_sen=(dks_sen16_rep_nov-dks_sen16_dem_nov)-(dks_sen16_rep_prim-dks_sen16_dem_prim)
gen dk_demadvant_gain_hou=(dks_hou16_rep_nov-dks_hou16_dem_nov)-(dks_hou16_rep_prim-dks_hou16_dem_prim)

*sort wustlid 
*merge wustlid using "C:\Users\ptucker\Dropbox\Campaign Effects\self_placement_issues.dta"
*drop _merge
*sort wustlid 
foreach x of varlist ISSUESGA1S60- ISSUESGA6S60 ISSUESGA9S60 ISSUESGA10S60{
recode `x' -1=. 1=1 2=-1 3=0
}
foreach x of varlist ISSUESGA7S60 ISSUESGA8S60{
recode `x' -1=. 1=-1 2=1 3=0
}
gen self_placement_issues_nov=ISSUESGA1S60+ISSUESGA2S60+ISSUESGA3S60+ISSUESGA4S60+ISSUESGA5S60+ISSUESGA6S60+ISSUESGA7S60+ISSUESGA8S60+ISSUESGA9S60+ISSUESGA10S60 

gen diff_issues_abs_dist_pres=(abs(id_pres16_rep_nov-self_placement_issues_nov)-abs(id_pres16_dem_nov-self_placement_issues_nov))-(abs(id_pres16_rep_prim-self_placement_issues_nov)-abs(id_pres16_dem_prim-self_placement_issues_nov))
gen diff_issues_abs_dist_sen=(abs(id_sen16_rep_nov-self_placement_issues_nov)-abs(id_sen16_dem_nov-self_placement_issues_nov))-(abs(id_sen16_rep_prim-self_placement_issues_nov)-abs(id_sen16_dem_prim-self_placement_issues_nov))
gen diff_issues_abs_dist_hou=(abs(id_hou16_rep_nov-self_placement_issues_nov)-abs(id_hou16_dem_nov-self_placement_issues_nov))-(abs(id_hou16_rep_prim-self_placement_issues_nov)-abs(id_hou16_dem_prim-self_placement_issues_nov))

*sort wustlid
*merge wustlid using "C:\Users\ptucker\Dropbox\Campaign Effects\id_location_movement.dta"
*drop _merge 

*****Just for 16
***Does a relative reduction in Don't knows, lead to a switch
gen dk_pres_TRUMPMAY=dk_demadvant_gain_pres*TRUMP_MAY
gen dk_sen_REPSEN16PRIM=dk_demadvant_gain_sen*REP16_SEN
gen dk_hou_REPHOU16PRIM=dk_demadvant_gain_hou*REP16_HOU

gen dk_pres_OTHERMAY=dk_demadvant_gain_pres*OTHER_MAY
gen dk_sen_OTHERSEN16PRIM=dk_demadvant_gain_sen*OTHER16_SEN
gen dk_hou_OTHERHOU16PRIM=dk_demadvant_gain_hou*OTHER16_HOU



*****With Squared Sophistication
***Table 4 and Table A6
**Table 4 Columns 7-9 & Table A6 Columns 7-9 
***President
logit NOV162PARTY_pres dk_pres_TRUMPMAY dk_pres_OTHERMAY dk_demadvant_gain_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY SOPHSQ SOPHSQ_TRUMPMAY SOPHSQ_OTHERMAY OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY abcpres100 absolute_closeness_pres_REP16100 abcp_OTHER16100 [pw=weights_pres16]
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom abcpres100
lincom dk_demadvant_gain_pres

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom SOPHSQ + SOPHSQ_TRUMPMAY
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom abcpres100 + absolute_closeness_pres_REP16100
lincom dk_demadvant_gain_pres + dk_pres_TRUMPMAY

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom SOPHSQ + SOPHSQ_OTHERMAY
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom abcpres100 + abcp_OTHER16100
lincom dk_demadvant_gain_pres + dk_pres_OTHERMAY

***Senate

***Senate model
**Right now without CA for robustness. 
**Table 4 Columns 4-6 & Table A6 Columns 4-6 
logit NOV162PARTY_sen dk_demadvant_gain_sen dk_sen_OTHERSEN16PRIM dk_sen_REPSEN16PRIM REP16_SEN OTHER16_SEN OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  SOPHSQ SOPHSQ_REPSEN16PRIM SOPHSQ_OTHERSEN16PRIM REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16 [pw=weights_sen16]  if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen
lincom dk_demadvant_gain_sen

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom SOPHSQ + SOPHSQ_REPSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16
lincom dk_demadvant_gain_sen + dk_sen_REPSEN16PRIM

***Initial Other
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom SOPHSQ + SOPHSQ_OTHERSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16
lincom dk_demadvant_gain_sen + dk_sen_OTHERSEN16PRIM

***House 16
**Table 4 Columns 4-6 & Table A6 Columns 4-6 
logit NOV162PARTY_hou dk_demadvant_gain_hou dk_hou_REPHOU16PRIM dk_hou_OTHERHOU16PRIM REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM SOPHSQ SOPHSQ_REPHOU16PRIM SOPHSQ_OTHER16PRIM REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM absolute_closeness_hou absolute_closeness_hou_REP16 absolute_closeness_hou_OTHER16 [pw=weights_hou16]
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_hou
lincom dk_demadvant_gain_hou

***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom SOPHSQ + SOPHSQ_REPHOU16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_REP16
lincom dk_demadvant_gain_hou + dk_hou_REPHOU16PRIM

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom SOPHSQ + SOPHSQ_OTHER16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_OTHER16
lincom dk_demadvant_gain_hou + dk_hou_OTHERHOU16PRIM


***President
logit NOV162PARTY_pres dk_pres_TRUMPMAY dk_pres_OTHERMAY dk_demadvant_gain_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY SOPHISTICATION SOPHISTICATION_TRUMPMAY SOPHISTICATION_OTHERMAY OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY abcpres100 absolute_closeness_pres_REP16100 abcp_OTHER16100 [pw=weights_pres16]
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom abcpres100
lincom dk_demadvant_gain_pres

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom SOPHISTICATION + SOPHISTICATION_TRUMPMAY
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom abcpres100 + absolute_closeness_pres_REP16100
lincom dk_demadvant_gain_pres + dk_pres_TRUMPMAY

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom SOPHISTICATION + SOPHISTICATION_OTHERMAY
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom abcpres100 + abcp_OTHER16100
lincom dk_demadvant_gain_pres + dk_pres_OTHERMAY

**Table A1
logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM mid_sophist mid_other_sen14 mid_rep_sen14 high_sophist high_other_sen14 high_rep_sen14 COOK_SEN_14 COOK_rep_sen14 COOK_other_sen14
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom mid_sophist
lincom high_sophist
lincom COOK_SEN_14


****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom mid_sophist + mid_rep_sen14
lincom high_sophist + high_rep_sen14
lincom COOK_SEN_14+COOK_rep_sen14
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM

***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom mid_sophist + mid_other_sen14
lincom high_sophist + high_other_sen14
lincom COOK_SEN_14+COOK_rep_sen14
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM mid_sophist mid_other_hou14 mid_rep_hou14 high_sophist high_other_hou14 high_rep_hou14 COOK_HOUSE_14 COOK_rep_hou14 COOK_other_hou14
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom mid_sophist
lincom high_sophist
lincom COOK_HOUSE_14


****Initial REP Sen
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom mid_sophist + mid_rep_hou14
lincom high_sophist + high_rep_hou14
lincom COOK_HOUSE_14+COOK_rep_hou14
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom mid_sophist + mid_other_hou14
lincom high_sophist + high_other_hou14
lincom COOK_HOUSE_14+COOK_other_hou14
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM





****Table A2
**Right now without CA for robustness. Zaller
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN   OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  mid_sophist high_sophist high_rep_sen16 mid_rep_sen16 mid_other_sen16 high_other_sen16 REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM COOK_SEN_16 COOK_rep_sen16 COOK_other_sen16  if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom mid_sophist
lincom high_sophist
lincom OBAMA_APPR_S60
lincom COOK_SEN_16

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom mid_sophist + mid_rep_sen16
lincom high_sophist + high_rep_sen16
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom COOK_SEN_16 + COOK_rep_sen16

***Initial Other 
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom mid_sophist + mid_other_sen16
lincom high_sophist + high_other_sen16
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom COOK_SEN_16 + COOK_other_sen16

****House
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM  mid_sophist high_sophist high_rep_hou16 mid_rep_hou16 mid_other_hou16 high_other_hou16 REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM COOK_HOUSE_16 COOK_rep_hou16 COOK_other_hou16
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom mid_sophist
lincom high_sophist
lincom OBAMA_APPR_S60
lincom COOK_HOUSE_16


***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom mid_sophist + mid_rep_hou16
lincom high_sophist + high_rep_hou16
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom COOK_HOUSE_16 + COOK_rep_hou16

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom mid_sophist + mid_other_hou16
lincom high_sophist + high_other_hou16
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom COOK_HOUSE_16 + COOK_other_hou16

logit NOV162PARTY_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY mid_sophist mid_other_pres16 mid_rep_pres16 high_sophist high_other_pres16 high_rep_pres16 OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY COOK_PRES COOK_rep_pres16 COOK_other_pres16
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom mid_sophist
lincom high_sophist
lincom OBAMA_APPR_S60
lincom COOK_PRES

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom mid_sophist + mid_rep_pres16
lincom high_sophist + high_rep_pres16
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom COOK_PRES + COOK_rep_pres16

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom mid_sophist + mid_other_pres16
lincom high_sophist + high_other_pres16
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom COOK_PRES + COOK_other_pres16



***Within 5
**Right now without CA for robustness. Table A3
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN   OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  mid_sophist high_sophist high_rep_sen16 mid_rep_sen16 mid_other_sen16 high_other_sen16 REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM within_five_sen_16 w5_other_sen16 w5_rep_sen16 if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom mid_sophist
lincom high_sophist
lincom OBAMA_APPR_S60
lincom within_five_sen_16

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom mid_sophist + mid_rep_sen16
lincom high_sophist + high_rep_sen16
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom within_five_sen_16+ w5_rep_sen16

***Initial Other 
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom mid_sophist + mid_other_sen16
lincom high_sophist + high_other_sen16
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom within_five_sen_16+ w5_other_sen16



****House
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM  mid_sophist high_sophist high_rep_hou16 mid_rep_hou16 mid_other_hou16 high_other_hou16 REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM within_five_hou_16 w5_rep_hou16 w5_other_hou16
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom mid_sophist
lincom high_sophist
lincom OBAMA_APPR_S60
lincom within_five_hou_16


***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom mid_sophist + mid_rep_hou16
lincom high_sophist + high_rep_hou16
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom within_five_hou_16+ w5_rep_hou16

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom mid_sophist + mid_other_hou16
lincom high_sophist + high_other_hou16
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom within_five_hou_16+ w5_other_hou16

logit NOV162PARTY_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY mid_sophist mid_other_pres16 mid_rep_pres16 high_sophist high_other_pres16 high_rep_pres16 OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY within_five_pres w5_rep_pres16 w5_other_pres16
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom mid_sophist
lincom high_sophist
lincom OBAMA_APPR_S60
lincom within_five_pres

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom mid_sophist + mid_rep_pres16
lincom high_sophist + high_rep_pres16
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom within_five_pres+ w5_rep_pres16

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom mid_sophist + mid_other_pres16
lincom high_sophist + high_other_pres16
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom within_five_pres+ w5_other_pres16

logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM mid_sophist mid_other_sen14 mid_rep_sen14 high_sophist high_other_sen14 high_rep_sen14 within_five_sen_14 w5_rep_sen14 w5_other_sen14
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom mid_sophist
lincom high_sophist
lincom within_five_sen_14


****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom mid_sophist + mid_rep_sen14
lincom high_sophist + high_rep_sen14
lincom within_five_sen_14+w5_rep_sen14
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM

***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom mid_sophist + mid_other_sen14
lincom high_sophist + high_other_sen14
lincom within_five_sen_14 + w5_other_sen14
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM mid_sophist mid_other_hou14 mid_rep_hou14 high_sophist high_other_hou14 high_rep_hou14 COOK_HOUSE_14 w5_rep_hou14 w5_other_hou14
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom mid_sophist
lincom high_sophist
lincom within_five_hou_14


****Initial REP Sen
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom mid_sophist + mid_rep_hou14
lincom high_sophist + high_rep_hou14
lincom within_five_hou_14 + w5_rep_hou14
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom mid_sophist + mid_other_hou14
lincom high_sophist + high_other_hou14
lincom within_five_hou_14 + w5_other_hou14
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM


****Table A4 
****Senate 14
logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM SOPHISTICATION SOPHISTICATION_REPSEN14PRIM SOPHISTICATION_OTHERSEN14PRIM abcsen14100 abcsen14_REP14100 abcsen14_OTHER14100 [pw=weights_sen14]
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHISTICATION
lincom abcsen14100


****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPSEN14PRIM
lincom abcsen14100+abcsen14_REP14100


***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHERSEN14PRIM
lincom abcsen14100+abcsen14_OTHER14100

**House 14
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHISTICATION SOPHISTICATION_REPHOU14PRIM SOPHISTICATION_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 [pw=weights_hou14]     

matrix V = e(V)

**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHISTICATION
lincom abchou14100


****Initial REP HOU
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPHOU14PRIM
lincom abchou14100+abchou14_REP14100


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHERHOU14PRIM
lincom abchou14100+abchou14_OTHER14100



*******Table A5
****Continuous Sophistication
logit NOV162PARTY_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY SOPHISTICATION SOPHISTICATION_TRUMPMAY SOPHISTICATION_OTHERMAY OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY abcpres100 absolute_closeness_pres_REP16100 abcp_OTHER16100 
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom abcpres100

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom SOPHISTICATION + SOPHISTICATION_TRUMPMAY
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom abcpres100 + absolute_closeness_pres_REP16100

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom SOPHISTICATION + SOPHISTICATION_OTHERMAY
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom abcpres100 + abcp_OTHER16100



***Senate model
**Right now without CA for robustness. 
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  SOPHISTICATION SOPHISTICATION_REPSEN16PRIM SOPHISTICATION_OTHERSEN16PRIM REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16 if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16

***Initial Other
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHERSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16

***House 16
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM  SOPHISTICATION SOPHISTICATION_REPHOU16PRIM SOPHISTICATION_OTHER16PRIM REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM absolute_closeness_hou absolute_closeness_hou_REP16 absolute_closeness_hou_OTHER16
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom absolute_closeness_hou

***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPHOU16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_REP16

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHER16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_OTHER16


****Table A7

****Senate 14
logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM high_sophist low_sophist high_rep_sen14 low_rep_sen14 high_other_sen14 low_other_sen14 abcsen14100 abcsen14_REP14100 abcsen14_OTHER14100 [pw=weights_sen14]
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom high_sophist
lincom low_sophist
lincom abcsen14100


****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM
lincom high_sophist + high_rep_sen14
lincom low_sophist + low_rep_sen14
lincom abcsen14100+abcsen14_REP14100


***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
lincom high_sophist + high_other_sen14
lincom low_sophist + low_other_sen14
lincom abcsen14100+abcsen14_OTHER14100

**House 14
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  high_sophist low_sophist high_rep_hou14 low_rep_hou14 high_other_hou14 low_other_hou14 abchou14100 abchou14_REP14100 abchou14_OTHER14100 [pw=weights_hou14]     

matrix V = e(V)

**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom high_sophist
lincom low_sophist
lincom abchou14100


****Initial REP HOU
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM
lincom high_sophist + high_rep_hou14
lincom low_sophist + low_rep_hou14
lincom abchou14100+abchou14_REP14100


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM
lincom high_sophist + high_other_hou14
lincom low_sophist + low_other_hou14
lincom abchou14100+abchou14_OTHER14100


****Table A8

****Categorical sophistication
***Presidential Model
logit NOV162PARTY_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY high_sophist high_other_pres16 high_rep_pres16 low_sophist low_other_pres16 low_rep_pres16 OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY abcpres100 absolute_closeness_pres_REP16100 abcp_OTHER16100 [pw=weights_pres16]
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom high_sophist
lincom low_sophist
lincom OBAMA_APPR_S60
lincom abcpres100

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom high_sophist + high_rep_pres16
lincom low_sophist + low_rep_pres16
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom abcpres100 + absolute_closeness_pres_REP16100

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom high_sophist + high_other_pres16
lincom low_sophist + low_other_pres16
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom abcpres100 + abcp_OTHER16100

**Right now without CA for robustness. Zaller
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN   OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  high_sophist low_sophist low_rep_sen16 high_rep_sen16 high_other_sen16 low_other_sen16 REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16 [pw=weights_sen16]  if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom high_sophist
lincom low_sophist
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom high_sophist + high_rep_sen16
lincom low_sophist + low_rep_sen16
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16

***Initial Other 
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom high_sophist + high_other_sen16
lincom low_sophist + low_other_sen16
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16

***House 16
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM high_sophist low_sophist low_rep_hou16 high_rep_hou16 high_other_hou16 low_other_hou16 REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM absolute_closeness_hou absolute_closeness_hou_REP16 absolute_closeness_hou_OTHER16 [pw=weights_hou16]
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom high_sophist
lincom low_sophist
lincom OBAMA_APPR_S60
lincom absolute_closeness_hou

***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom high_sophist + high_rep_hou16
lincom low_sophist + low_rep_hou16
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_REP16

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom high_sophist + high_other_hou16
lincom low_sophist + low_other_hou16
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_OTHER16

****Table A9
****Senate 14
logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM SOPHISTICATION SOPHISTICATION_REPSEN14PRIM SOPHISTICATION_OTHERSEN14PRIM abcsen14100 abcsen14_REP14100 abcsen14_OTHER14100 [pw=weights_sen14]
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHISTICATION
lincom abcsen14100


****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPSEN14PRIM
lincom abcsen14100+abcsen14_REP14100


***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHERSEN14PRIM
lincom abcsen14100+abcsen14_OTHER14100

**House 14
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHISTICATION SOPHISTICATION_REPHOU14PRIM SOPHISTICATION_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 [pw=weights_hou14]     

matrix V = e(V)

**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHISTICATION
lincom abchou14100


****Initial REP HOU
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPHOU14PRIM
lincom abchou14100+abchou14_REP14100


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHERHOU14PRIM
lincom abchou14100+abchou14_OTHER14100


***Table A10
****Continuous Sophistication
logit NOV162PARTY_pres TRUMP_MAY OTHER_MAY REP_MAXN REP_TRUMPMAY REP_OTHERMAY DEM_MAXN DEM_TRUMPMAY DEM_OTHERMAY SOPHISTICATION SOPHISTICATION_TRUMPMAY SOPHISTICATION_OTHERMAY OBAMA_APPR_S60 OBAMA_TRUMPMAY OBAMA_OTHERMAY abcpres100 absolute_closeness_pres_REP16100 abcp_OTHER16100 [pw=weights_pres16]
matrix V = e(V)
**Initial Clinton Voter
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom abcpres100

***Initial Trump Voter
lincom TRUMP_MAY + _cons 
lincom REP_MAXN + REP_TRUMPMAY
lincom DEM_MAXN + DEM_TRUMPMAY
lincom SOPHISTICATION + SOPHISTICATION_TRUMPMAY
lincom OBAMA_APPR_S60 + OBAMA_TRUMPMAY
lincom abcpres100 + absolute_closeness_pres_REP16100

***Initial Other Voter
lincom OTHER_MAY + _cons 
lincom REP_MAXN + REP_OTHERMAY
lincom DEM_MAXN + DEM_OTHERMAY
lincom SOPHISTICATION + SOPHISTICATION_OTHERMAY
lincom OBAMA_APPR_S60 + OBAMA_OTHERMAY
lincom abcpres100 + abcp_OTHER16100



***Senate model
**Right now without CA for robustness. 
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  SOPHISTICATION SOPHISTICATION_REPSEN16PRIM SOPHISTICATION_OTHERSEN16PRIM REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16 [pw=weights_sen16]  if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16

***Initial Other
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHERSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16

***House 16
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM  SOPHISTICATION SOPHISTICATION_REPHOU16PRIM SOPHISTICATION_OTHER16PRIM REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM absolute_closeness_hou absolute_closeness_hou_REP16 absolute_closeness_hou_OTHER16 [pw=weights_hou16]
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHISTICATION
lincom OBAMA_APPR_S60
lincom absolute_closeness_hou

***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom SOPHISTICATION + SOPHISTICATION_REPHOU16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_REP16

***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom SOPHISTICATION + SOPHISTICATION_OTHER16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_OTHER16


***Table A11
***Predicting undecided
logit OTHER_MAY SOPHISTICATION REP_MAXN DEM_MAXN OBAMA_APPR_S60  abcpres100 [pw=weights_pres16] if NOV162PARTY_pres==0 | NOV162PARTY_pres==1
logit OTHER16_SEN SOPHISTICATION REP_MAXN DEM_MAXN OBAMA_APPR_S60  absolute_closeness_sen [pw=weights_sen16] if NOV162PARTY_sen==0 | NOV162PARTY_sen==1 & XPPSTATE!=93
logit OTHER16_HOU SOPHISTICATION REP_MAXN DEM_MAXN OBAMA_APPR_S60  absolute_closeness_hou [pw=weights_hou16] if NOV162PARTY_hou==0 | NOV162PARTY_hou==1 
logit OTHER14_SEN SOPHISTICATION REP_MAXN DEM_MAXN OBAMA_APPR_S36  abcsen14100 [pw=weights_sen14] if NOV142PARTY_sen==0 | NOV142PARTY_sen==1
logit OTHER14_HOU SOPHISTICATION REP_MAXN DEM_MAXN OBAMA_APPR_S36  abchou14100 [pw=weights_hou14] if NOV142PARTY_hou==0 | NOV142PARTY_hou==1 

****Table A12
****Senate 14 advantage
logit NOV142PARTY_sen REP14_SEN OTHER14_SEN REP_MAXN  REP_REPSEN14PRIM REP_OTHERSEN14PRIM  DEM_MAXN DEM_REPSEN14PRIM DEM_OTHERSEN14PRIM OBAMA_APPR_S36 OBAMA_REPSEN14PRIM OBAMA_OTHERSEN14PRIM SOPHSQ SOPHSQ_REPSEN14PRIM SOPHSQ_OTHERSEN14PRIM abcsen14100 abcsen14_REP14100 abcsen14_OTHER14100  senaterepadv_14 repadv_REPSEN14PRIM repadv_OTHERSEN14PRIM [pw=weights_sen14]
matrix V = e(V)

**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHSQ
lincom abcsen14100
lincom senaterepadv_14

****Initial REP Sen
lincom REP14_SEN + _cons 
lincom REP_MAXN + REP_REPSEN14PRIM
lincom DEM_MAXN + DEM_REPSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPSEN14PRIM
lincom SOPHSQ + SOPHSQ_REPSEN14PRIM
lincom abcsen14100+abcsen14_REP14100
lincom senaterepadv_14 + repadv_REPSEN14PRIM

***Initial Other
lincom OTHER14_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN14PRIM
lincom DEM_MAXN + DEM_OTHERSEN14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERSEN14PRIM
lincom SOPHSQ + SOPHSQ_OTHERSEN14PRIM
lincom abcsen14100+abcsen14_OTHER14100
lincom senaterepadv_14 + repadv_OTHERSEN14PRIM

**House 14 
logit NOV142PARTY_hou REP14_HOU OTHER14_HOU REP_MAXN  REP_REPHOU14PRIM REP_OTHERHOU14PRIM  DEM_MAXN DEM_REPHOU14PRIM DEM_OTHERHOU14PRIM OBAMA_APPR_S36 OBAMA_REPHOU14PRIM OBAMA_OTHERHOU14PRIM  SOPHSQ SOPHSQ_REPHOU14PRIM SOPHSQ_OTHERHOU14PRIM abchou14100 abchou14_REP14100 abchou14_OTHER14100 rep_spend_advantage repadv_REPHOU14PRIM repadv_OTHERHOU14PRIM [pw=weights_hou14]     

matrix V = e(V)

**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom OBAMA_APPR_S36
lincom SOPHSQ
lincom abchou14100
lincom rep_spend_advantage

****Initial REP HOU
lincom REP14_HOU + _cons 
lincom REP_MAXN + REP_REPHOU14PRIM
lincom DEM_MAXN + DEM_REPHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_REPHOU14PRIM
lincom SOPHSQ + SOPHSQ_REPHOU14PRIM
lincom abchou14100+abchou14_REP14100
lincom rep_spend_advantage + repadv_REPHOU14PRIM


***Initial Other
lincom OTHER14_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU14PRIM
lincom DEM_MAXN + DEM_OTHERHOU14PRIM
lincom OBAMA_APPR_S36 + OBAMA_OTHERHOU14PRIM
lincom SOPHSQ + SOPHSQ_OTHERHOU14PRIM
lincom abchou14100+abchou14_OTHER14100
lincom rep_spend_advantage + repadv_OTHERHOU14PRIM


****Table A13
***Senate model
**Right now without CA for robustness. 
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  SOPHSQ SOPHSQ_REPSEN16PRIM SOPHSQ_OTHERSEN16PRIM REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16  rep_spend_advantage_16 repadv_REPSEN16PRIM repadv_OTHERSEN16PRIM [pw=weights_sen16]  if STATE!="CA"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen
lincom rep_spend_advantage_16

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom SOPHSQ + SOPHSQ_REPSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16
lincom rep_spend_advantage_16 + repadv_REPSEN16PRIM


***Initial Other
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom SOPHSQ + SOPHSQ_OTHERSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16
lincom rep_spend_advantage_16 + repadv_OTHERSEN16PRIM


***House 16
logit NOV162PARTY_hou REP16_HOU OTHER16_HOU  OBAMA_APPR_S60 OBAMA_REPHOU16PRIM OBAMA_OTHERHOU16PRIM  SOPHSQ SOPHSQ_REPHOU16PRIM SOPHSQ_OTHER16PRIM REP_MAXN REP_REPHOU16PRIM REP_OTHERHOU16PRIM DEM_MAXN DEM_REPHOU16PRIM DEM_OTHERHOU16PRIM absolute_closeness_hou absolute_closeness_hou_REP16 absolute_closeness_hou_OTHER16    rep_spend_advantage_16 repadv_REPHOU16PRIM repadv_OTHER16PRIM [pw=weights_hou16]
matrix V = e(V)
**Initial Dem HOU
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_hou
lincom rep_spend_advantage_16

***Initial Republican
****Initial REP HOUator
lincom REP16_HOU + _cons 
lincom REP_MAXN + REP_REPHOU16PRIM
lincom DEM_MAXN + DEM_REPHOU16PRIM
lincom SOPHSQ + SOPHSQ_REPHOU16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_REP16
lincom rep_spend_advantage_16 + repadv_REPHOU16PRIM


***Initial Other
lincom OTHER16_HOU + _cons 
lincom REP_MAXN + REP_OTHERHOU16PRIM
lincom DEM_MAXN + DEM_OTHERHOU16PRIM
lincom SOPHSQ + SOPHSQ_OTHER16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERHOU16PRIM
lincom absolute_closeness_hou + absolute_closeness_hou_OTHER16
lincom rep_spend_advantage_16 + repadv_OTHER16PRIM

***Table A14
***Without Arizona and Indiana
**Right now without CA for robustness. 
logit NOV162PARTY_sen REP16_SEN OTHER16_SEN OBAMA_APPR_S60 OBAMA_REPSEN16PRIM OBAMA_OTHERSEN16PRIM  SOPHSQ SOPHSQ_REPSEN16PRIM SOPHSQ_OTHERSEN16PRIM REP_MAXN REP_REPSEN16PRIM REP_OTHERSEN16PRIM DEM_MAXN DEM_REPSEN16PRIM DEM_OTHERSEN16PRIM absolute_closeness_sen absolute_closeness_sen_REP16 absolute_closeness_sen_OTHER16    [pw=weights_sen16]  if STATE!="CA" & STATE!="AZ" & STATE!="IN"
matrix V = e(V)
**Initial Dem Sen
lincom _cons
lincom REP_MAXN
lincom DEM_MAXN
lincom SOPHSQ
lincom OBAMA_APPR_S60
lincom absolute_closeness_sen

***Initial Republican
****Initial REP Senator
lincom REP16_SEN + _cons 
lincom REP_MAXN + REP_REPSEN16PRIM
lincom DEM_MAXN + DEM_REPSEN16PRIM
lincom SOPHSQ + SOPHSQ_REPSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_REPSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_REP16

***Initial Other
lincom OTHER16_SEN + _cons 
lincom REP_MAXN + REP_OTHERSEN16PRIM
lincom DEM_MAXN + DEM_OTHERSEN16PRIM
lincom SOPHSQ + SOPHSQ_OTHERSEN16PRIM
lincom OBAMA_APPR_S60 + OBAMA_OTHERSEN16PRIM
lincom absolute_closeness_sen + absolute_closeness_sen_OTHER16

****Figures for figure
expand 2
egen seq=fill(1 2 1 2)
gen dks_hou16_pool_prim=dks_hou16_dem_prim if seq==1
replace dks_hou16_pool_prim=dks_hou16_rep_prim if seq==2

gen dks_hou16_pool_nov=dks_hou16_dem_nov if seq==1
replace dks_hou16_pool_nov=dks_hou16_rep_nov if seq==2

gen dks_sen16_pool_prim=dks_sen16_dem_prim if seq==1
replace dks_sen16_pool_prim=dks_sen16_rep_prim if seq==2

gen dks_sen16_pool_nov=dks_sen16_dem_nov if seq==1
replace dks_sen16_pool_nov=dks_sen16_rep_nov if seq==2

gen dks_pres16_pool_prim=dks_pres16_dem_prim if seq==1
replace dks_pres16_pool_prim=dks_pres16_rep_prim if seq==2

gen dks_pres16_pool_nov=dks_pres16_dem_nov if seq==1
replace dks_pres16_pool_nov=dks_pres16_rep_nov if seq==2

mean dks_hou16_pool_prim
mean dks_hou16_pool_nov
mean dks_sen16_pool_prim
mean dks_sen16_pool_nov
mean dks_pres16_pool_prim
mean dks_pres16_pool_nov

